﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Promotion.ascx.cs" Inherits="Admin_Components_MasterData_Promotion" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True">
</telerik:RadScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        
          <telerik:RadTabStrip ID="TabStrip1" runat="server" EnableDragToReorder="true" Skin="Vista" MultiPageID="RadMultiPag1" SelectedIndex="1">
            <Tabs>
                <telerik:RadTab Text="CHƯƠNG TRÌNH KHUYẾN MÃI" Selected="True">
                </telerik:RadTab>
                <telerik:RadTab Text="CHI TIẾT KHUYẾN MÃI">
                </telerik:RadTab>
                 <telerik:RadTab Text="TÌM KIẾM">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPag1" runat="server" SelectedIndex="0">
            <!--Tab thông tin chung -->
            <telerik:RadPageView ID="RadPageView1" runat="server" Height="200px" Style="overflow: hidden">
                 <fieldset class="form" id="fsGeneral">
                  <br />
                <div class="form-horizontal wrapper-center clearfix">
                    <!--Block bên trái -->
                 <div class="form-group col-md-6">
                  <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Tên KM <span style="color:red;">(*)</span></label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtPromotionName" CssClass="col-imp-12 inputForm" runat="server" />
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPromotionName" ValidationGroup="g1"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                    </div>
                                      
                     
                  <!--End Dòng -->
                     <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Loại</label>
                        <div class="col-md-3">
                            <telerik:RadComboBox ID="cboPromotionType" runat="server" CssClass="col-imp-12" OnSelectedIndexChanged="cboPromotionType_SelectedIndexChanged" AutoPostBack="true" >
                            </telerik:RadComboBox>
                        </div>
                    </div>
                  <!--End Dòng -->
                 <!--Dòng -->
                    <div class="form-group" id="PrmotionAmount" runat="server">
                        <label class="col-md-3 control-label">
                           Tổng tiền tích lũy <span style="color:red;">(*)</span></label>
                        <div class="col-md-3">
                            <telerik:RadNumericTextBox ID="txtAmount" CssClass="col-md-4 inputForm"  NumberFormat-DecimalDigits="0" MinValue="0" runat="server"/>
                              <asp:RequiredFieldValidator  ID="RequiredtxtAmount" runat="server" ControlToValidate="txtAmount" ValidationGroup="g1"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                        <label class="col-md-3 control-label">Giảm giá(VNĐ) <span style="color:red;">(*)</span></label>
                        <div class="col-md-2">
                            <telerik:RadNumericTextBox ID="txtDiscount" NumberFormat-DecimalDigits="0" MinValue="0" CssClass="col-md-3 inputForm"  runat="server"/>
                              <asp:RequiredFieldValidator  ID="RequiredtxtDiscount" runat="server" ControlToValidate="txtDiscount" ValidationGroup="g1"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                    </div>
                  <!--End Dòng -->
                </div>
                 <!--End Block bên trái -->
                     <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <div class="form-group">
                        <label class="col-md-3 control-label">Từ ngày</label>
                        <div class="col-md-8">
                          <telerik:RadDatePicker ID="dtpFromDate" cssclass="col-imp-8" enabled="true" runat="server">
                                <Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput Enabled="False" style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"></DateInput>
                            </telerik:RadDatePicker>
                         </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">Đến ngày</label>
                        <div class="col-md-8">
                            <telerik:RadDatePicker ID="dtpToDate" cssclass="col-imp-8" enabled="true" runat="server">
                                <Calendar ID="Calendar2" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput Enabled="False" style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"></DateInput>
                            </telerik:RadDatePicker>
                         </div>

                    </div>
                     <div class="form-group">
                        <label class="col-md-3 control-label">Tình trạng</label>
                        <div class="col-md-8">
                             <telerik:RadComboBox ID="cboPromotionStatus" runat="server" CssClass="col-imp-4">
                            </telerik:RadComboBox>
                         </div>
                    </div>
                
                </div>
                 <!--End Block bên phải -->
                </div>
                      <!--Action-->
                    <div class="set-btns text-center">
                        <asp:Button ID="btnSave" CssClass="btn btn-sm btn-primary" runat="server" Text="Lưu" OnClick="btnSave_Click" ValidationGroup="g1" OnClientClick="fnOnUpdateValidators('g1');"/>
                        <asp:Button ID="btnCancel" runat="server" CssClass="btn btn-sm btn-warning" 
                            Text="Hủy" onclick="btnCancel_Click" OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn hủy?')"/>
                        <asp:Button ID="btnReset" runat="server" CssClass="btn btn-sm btn-primary" Text="Tạo mới" OnClick="btnReset_Click"/>
                    </div>
                    <!--End Action -->
                </fieldset>
            </telerik:RadPageView>
             <telerik:RadPageView ID="RadPageView2" runat="server"  Height="180px" Style="overflow: hidden">                
                <fieldset class="form" id="Fieldset1">
                <br />
                    <div class="form-horizontal wrapper-center clearfix">
                         <div class="row col-md-12">
                          <div class="form-group text-left" style="margin-left:5px;">
                            <telerik:RadComboBox ID="cboProduct" runat="server" CssClass="col-imp-4" EmptyMessage="Nhập mã sản phẩm hoặc tên sản phẩm" filter="Contains">
                            </telerik:RadComboBox>
                             <telerik:RadComboBox ID="cboWeight" runat="server" CssClass="col-imp-2 inputForm comboRequired" EmptyMessage="Trọng lượng (kg)" ></telerik:RadComboBox>
                           <%--  <telerik:RadNumericTextBox ID="txtQuantityPack" runat="server" NumberFormat-DecimalDigits="0" MinValue="0" CssClass="col-imp-2 inputForm"/>--%>
                            <asp:Button ID="btnAddProduct" CssClass="btn btn-sm btn-primary" runat="server" Text="Thêm" OnClick="btnAdd_Click" ValidationGroup="g2" OnClientClick="fnOnUpdateValidators('g2');"/>
                        </div>
                        <div>
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator2" runat="server" ControlToValidate="cboProduct" ValidationGroup="g2"
                            ErrorMessage=""></asp:RequiredFieldValidator>
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator3" runat="server" ControlToValidate="cboWeight" ValidationGroup="g2"
                            ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                            <div class="row" style="width:57%">
                                <telerik:radgrid id="gvData" runat="server" cellspacing="0" cssclass=" table table-bordered"
                                    gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center" OnItemCommand="grvData_ItemCommand"
                                    allowmultirowselection="True" headerstyle-borderstyle="None">
                                    <MasterTableView ShowHeader="true" NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" EditMode="InPlace">
                                    <Columns>
                                        <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <%# Container.ItemIndex + 1 %></ItemTemplate>
                                            <HeaderStyle Width="50px" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </telerik:GridTemplateColumn>
                                         <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                            UniqueName="ProductID" DataField="ProductID" Display="false">
                                        <HeaderStyle HorizontalAlign="Center" ></HeaderStyle>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                        </telerik:GridBoundColumn>
                                         <telerik:GridBoundColumn  DataField="ProductName" UniqueName="ProductName"  ReadOnly="true" HeaderText="Tên quà tặng">
                                            <HeaderStyle HorizontalAlign="Center" Width ="300px"/>
                                            <ItemStyle HorizontalAlign="Left" Width ="300px" Font-Bold ="true"/>
                                        </telerik:GridBoundColumn>
                                         <telerik:GridBoundColumn  DataField="Weight" UniqueName="Weight"  Display="false" ReadOnly="true" >
                                        </telerik:GridBoundColumn>
                                         <telerik:GridBoundColumn  DataField="ProductWeight" UniqueName="ProductWeight"  ReadOnly="true" HeaderText="Loại quà tặng">
                                           <HeaderStyle HorizontalAlign="Center" Width ="70px"/>
                                            <ItemStyle HorizontalAlign="Center" Width ="70px"/>
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn  HeaderText="Số lượng">
                                        <ItemTemplate>
                                            <telerik:RadNumericTextBox ID="txtQuantity" runat="server" Text='<%#Eval("Quantity") %>'
                                                NumberFormat-DecimalDigits="0" MinValue="0" CssClass="col-imp-7 inputForm"/>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Right" Width="60px" />
                                        <ItemStyle HorizontalAlign="Right" Width="60px" />
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn HeaderText="Xóa" Visible=true HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:Button ID="lnkEditDel" CssClass="btnX" CommandArgument='<%# Eval("ProductID") %>'
                                                OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa?')" CommandName="EditDelItem"
                                                runat="server"></asp:Button>
                                        </ItemTemplate>
                                        <HeaderStyle Width="30px"/>
                                            <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridTemplateColumn>
                                    </Columns>
                                </MasterTableView>
                                </telerik:radgrid>
                            </div>
                        </div>
                    </div>
                </fieldset>
            </telerik:RadPageView>
            <!--Tim kiem -->
            <telerik:RadPageView ID="RadPageView3" runat="server" Height="190px" Style="overflow: hidden">
                 <fieldset class="form" id="Fieldset2">
                  <br />
                <div class="form-horizontal wrapper-center clearfix">
                    <!--Block bên trái -->
                 <div class="form-group col-md-6">
                  <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Tên chương trình KM</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtPromotionNameSearch" CssClass="col-imp-12 inputForm" runat="server" />
                        </div>
                    </div>
                                      
                     
                  <!--End Dòng -->
                     <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Loại</label>
                        <div class="col-md-3">
                            <telerik:RadComboBox ID="cboPromotionTypeSearch" runat="server" CssClass="col-imp-10">
                            </telerik:RadComboBox>
                        </div>
                        <label class="col-md-2 control-label">
                            Tình trạng</label>
                        <div class="col-md-3">
                            <telerik:RadComboBox ID="cboPromotionStatusSearch" runat="server" CssClass="col-imp-12">
                            </telerik:RadComboBox>
                        </div>
                    </div>
                  <!--End Dòng -->
                
                </div>
                 <!--End Block bên trái -->
                     <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <div class="form-group">
                        <label class="col-md-3 control-label">Từ ngày</label>
                        <div class="col-md-8">
                          <telerik:RadDatePicker ID="rtpFromDateSearch" cssclass="col-imp-8" enabled="true" runat="server">
                                <Calendar ID="Calendar3" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput  style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"></DateInput>
                            </telerik:RadDatePicker>
                         </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">Đến ngày</label>
                        <div class="col-md-8">
                            <telerik:RadDatePicker ID="rtpToDateSearch" cssclass="col-imp-8" enabled="true" runat="server">
                                <Calendar ID="Calendar4" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput  style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"></DateInput>
                            </telerik:RadDatePicker>
                         </div>
                    </div>
                  
                </div>
                 <!--End Block bên phải -->
                     
                </div>
                <div class="set-btns text-center">
                     <asp:Button ID="btnSearch" CssClass="btn btn-sm btn-primary" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click" />
                </div>
                </fieldset>
            </telerik:RadPageView>

        </telerik:RadMultiPage>
           
             <div class="row">
               <telerik:radgrid id="gv" runat="server" cellspacing="0" cssclass=" table table-bordered"
                    AllowPaging="true"
                    PageSize="50" AllowCustomPaging="true" OnNeedDataSource="gv_NeedDataSource" OnItemDataBound="gv_ItemDataBound"
                    gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center" OnItemCommand="gv_ItemCommand"
                    allowmultirowselection="True" headerstyle-borderstyle="None">
                    <MasterTableView ShowHeader="true" NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" EditMode="InPlace"  PageSize="50">
                        <Columns>
                            <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <%# Container.ItemIndex + 1 %></ItemTemplate>
                                <HeaderStyle Width="50px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                    UniqueName="PromotionID" DataField="PromotionID" Display="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                    UniqueName="PromotionName" DataField="PromotionName" HeaderText="Tên chương trình KM">
                                <HeaderStyle HorizontalAlign="Center" Width="200px" />
                                <ItemStyle HorizontalAlign="Left"  Width="200px"/>
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                 UniqueName="ProductType" DataField="ProductType"  HeaderText="Loại">
                                <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                <ItemStyle HorizontalAlign="Center"  Width="70px"/>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                 UniqueName="StartDate" DataField="StartDate"  HeaderText="Ngày bắt đầu" DataFormatString="{0:dd/MM/yyyy}">
                                <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                <ItemStyle HorizontalAlign="Center"  Width="100px"/>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                 UniqueName="EndDate" DataField="EndDate"  HeaderText="Ngày kết thúc" DataFormatString="{0:dd/MM/yyyy}">
                                   <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                   <ItemStyle HorizontalAlign="Center"  Width="100px"/>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                 UniqueName="Status" DataField="Status"  HeaderText="Tình trạng">
                                 <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                <ItemStyle HorizontalAlign="Center"  Width="100px"/>
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn HeaderText="Xóa" Visible=true HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Button ID="btnDelete" CssClass="btnX" CommandArgument='<%# Eval("PromotionID") %>'
                                        OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa?')" CommandName="EditDelItem"
                                        runat="server"></asp:Button>
                                </ItemTemplate>
                                <HeaderStyle Width="30px"/>
                               <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn  HeaderText="Chi tiết" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Button ID="btnDetail" runat="server" CssClass="btnViewDetail" CommandArgument='<%# Eval("PromotionID") %>'
                                    CommandName="DetailItem" Target="_blank"/>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="30px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                            UniqueName="StatusCode" DataField="StatusCode" Display="false">
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
               </telerik:radgrid>
             </div>
    </ContentTemplate>
</asp:UpdatePanel>
<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>
